# Adogs
# 时间: 2021/7/15 20:38
import pygame
from actor.action_character import ActionImageCharater


class WinOrLose(pygame.sprite.Sprite):
    """
    失败或成功的精灵函数
    方法:
    1.__init__(x,y,judge)
    2.draw(surface,x,y)
    3.run()
    """
    def __init__(self, x: int, y: int, judge):
        """
        初始化函数
        :param x: 精灵初始x坐标
        :param y: 精灵初始y坐标
        :param judge: 判断是失败还是成功精灵
        """
        super(WinOrLose, self).__init__()
        if judge == "win":
            self.action = ActionImageCharater("resources/picture/win_game/w_%d.png", 7, True)
        else:
            self.action = ActionImageCharater("resources/picture/lose_game/f_%d.png", 9, True)
        self.pos_x = x
        self.pos_y = y

    def draw(self, surface: pygame.surface, x: int, y: int):
        """
        绘制函数
        :param surface: 绘制屏幕
        :param x: 精灵x坐标
        :param y: 精灵y坐标
        :return: 无返回值
        """
        current_img = self.action.get_image()
        surface.blit(current_img, (self.pos_x - x, self.pos_y - y))

    def run(self):
        """
        精灵运动函数
        :return: 无返回值
        """
        if self.pos_x < 1050:
            self.pos_x += 4
